// FZ_BPA.cpp: implementation of the CFZ_BPA class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "../../Include/Swi/FZ_BPA.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CFZ_BPA::CFZ_BPA()
{
	m_chType = 'F';
	m_chSubType = 'Z';
	m_chChangeCode = ' ';

	m_dSe1 = 0;
	m_dSe2 = 0;
	m_dEfdMin = 0;
	m_dEfd1 = 0;
	m_dKf = 0;
	m_dTf = 0;
	m_dKc = 0;
	m_dKd = 0;
	m_dKb = 0;
	m_dKl = 0;
	m_dKh = 0;
	m_dVlr = 0;

	m_strCardType[0] = 'F';
	m_strCardType[1] = 'Z';
}

CFZ_BPA::CFZ_BPA(CFZ_BPA &fzBPA):CUnit_BPA(fzBPA)
{
	m_dSe1 = fzBPA.m_dSe1;
	m_dSe2 = fzBPA.m_dSe2;
	m_dEfdMin = fzBPA.m_dEfdMin;
	m_dEfd1 = fzBPA.m_dEfd1;
	m_dKf = fzBPA.m_dKf;
	m_dTf = fzBPA.m_dTf;
	m_dKc = fzBPA.m_dKc;
	m_dKd = fzBPA.m_dKd;
	m_dKb = fzBPA.m_dKb;
	m_dKl = fzBPA.m_dKl;
	m_dKh = fzBPA.m_dKh;
	m_dVlr = fzBPA.m_dVlr;
}

CFZ_BPA::~CFZ_BPA()
{

}

bool CFZ_BPA::FillEx(char *buffer)
{
	bool bResult = CUnit_BPA::FillEx(buffer);

	if (!bResult)
	{
		printf("Error in (CFZ_BPA::FillEx): no basic information!\n");
		return false;
	}

	if (strlen(buffer)<17)
		return true;

	m_dSe1 = StrToDouble(&buffer[16],5,3);
	if(EndOfSec(&buffer[16],5))
		return true;

	m_dSe2 = StrToDouble(&buffer[21],5,3);
	if(EndOfSec(&buffer[21],5))
		return true;

	m_dEfdMin = StrToDouble(&buffer[26],5,3);
	if(EndOfSec(&buffer[26],5))
		return true;

	m_dEfd1 = StrToDouble(&buffer[31],5,3);
	if(EndOfSec(&buffer[31],5))
		return true;

	m_dKf = StrToDouble(&buffer[36],5,3);
	if(EndOfSec(&buffer[36],5))
		return true;

	m_dTf = StrToDouble(&buffer[41],5,3);
	if(EndOfSec(&buffer[41],5))
		return true;

	m_dKc = StrToDouble(&buffer[46],5,4);
	if(EndOfSec(&buffer[46],5))
		return true;

	m_dKd = StrToDouble(&buffer[51],5,4);
	if(EndOfSec(&buffer[51],5))
		return true;

	m_dKb = StrToDouble(&buffer[56],5,3);
	if(EndOfSec(&buffer[56],5))
		return true;

	m_dKl = StrToDouble(&buffer[61],5,3);
	if(EndOfSec(&buffer[61],5))
		return true;

	m_dKh = StrToDouble(&buffer[66],5,3);
	if(EndOfSec(&buffer[66],5))
		return true;

	m_dVlr = StrToDouble(&buffer[71],5,3);
	if(EndOfSec(&buffer[71],5))
		return true;

	return true;
}

bool CFZ_BPA::UpdateEx(char *buffer)
{
	bool bResult = CUnit_BPA::UpdateEx(buffer);

	if (!bResult)
	{
		printf("Error in (CFZ_BPA::UpdateEx): impossible!\n");
		return false;
	}

	DoubleToStr(m_dSe1,&buffer[16],5,3);
	DoubleToStr(m_dSe2,&buffer[21],5,3);
	DoubleToStr(m_dEfdMin,&buffer[26],5,3);
	DoubleToStr(m_dEfd1,&buffer[31],5,3);
	DoubleToStr(m_dKf,&buffer[36],5,3);
	DoubleToStr(m_dTf,&buffer[41],5,3);
	DoubleToStr(m_dKc,&buffer[46],5,4);
	DoubleToStr(m_dKd,&buffer[51],5,4);
	DoubleToStr(m_dKb,&buffer[56],5,3);
	DoubleToStr(m_dKl,&buffer[61],5,3);
	DoubleToStr(m_dKh,&buffer[66],5,3);
	DoubleToStr(m_dVlr,&buffer[71],5,3);

	return true;
}